from selenium.webdriver.common.by import By
from Base.Base import Base

class Page(Base):
    # 登录按钮
    login=(By.CLASS_NAME,'headerLogin')
    # 断言账号登录
    userlogin=(By.CSS_SELECTOR,'.userLogin.on')
    #输入账号
    username = (By.ID,'userName')
    #输入密码
    password = (By.NAME,'_pwd')
    # 等待输入验证码
    # 点击登录按钮 绝对路径
    login1 = (By.XPATH,'/html/body/div/form/div/div/div/div/div[1]/div[2]/div[4]/input')
    # 警告确定 通配符
    qd = (By.XPATH,'//*[@id="bindSub"]')
    # 搜索框定位 键盘ENter
    srk = (By.XPATH,'//input[@id="wd" and @class="search-form"]')
    # 选择商品 鼠标单击
    shop = (By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')
    # 加入购物车
    addbuy=(By.LINK_TEXT,'加入购物车')
    # 查看购物车
    select = (By.NAME,'detail_chakangouwuche')
    # 断言2
    dy2 = (By.XPATH,'/html/body/div[3]/div/div[2]/div[2]/p/a[1]')
    # 断言3
    dy3=(By.CLASS_NAME,'level.level2')
    # 断言4
    dy4 = (By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[2]/p[1]/span')
    # 断言5 商品
    dy5 = (By.CLASS_NAME,'prom-h')
    #断言6 进入购物车
    dy6 = (By.CLASS_NAME,'my-cart-tit')
    def dy2_loc(self):
        return self.dy(self.dy2)
    def dy3_loc(self):
        return self.dy(self.dy3)
    def dy4_loc(self):
        return self.dy(self.dy4)
    def dy5_loc(self):
        return self.dy(self.dy5)
    def dy6_loc(self):
        return self.dy(self.dy6)

    def login_loc(self):
        self.click(self.login)
    def userlogin_loc(self):
        return self.dy(self.userlogin)
    def username_loc(self):
        self.send_keys(self.username,'15232008902')
    def password_loc(self):
        self.send_keys(self.password,'123456Aa')
    def login1_loc(self):
        self.click(self.login1)
    def qd_loc(self):
        self.click(self.qd)
    def srk_loc(self):
        self.send_keys(self.srk,'我的大学')
    def srk_loc1(self):
        self.keys_ENTER(self.srk)
    def shop_loc(self):
        self.action_click(self.shop)
    def addbuy_loc(self):
        self.click(self.addbuy)
    def select_loc(self):
        self.click(self.select)

